#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'

const int INF = 1 << 20;
const int maxn = 7;
int dis[maxn][maxn] = {{0,   INF, INF, INF, INF, INF, INF,},
                       {INF, 0,   1,   2,   INF, INF, INF,},
                       {INF, 1,   0,   6,   11,  INF, INF,},
                       {INF, 2,   6,   0,   9,   13,  INF,},
                       {INF, INF, 11,  9,   0,   7,   3,},
                       {INF, INF, INF, 13,  7,   0,   4,},
                       {INF, INF, INF, INF, 3,   4,   0,},
};
int n = 6;

int Prim(int v) {
    int tot = 0;
    int lowcost[maxn], closest[maxn], mincost;
    fill(lowcost, lowcost + n + 1, INF);
    for (int j = 1; j <= n; j++) {
        lowcost[j] = dis[v][j];
        closest[j] = v;
    }
    for (int i = 1; i <= n; i++) {
        if ( i == v )continue;
        mincost = INF;
        int k = 1;
        for (int j = 1; j <= n; j++) {
            if ( lowcost[j] != 0 && lowcost[j] < mincost ) {
                mincost = lowcost[j];
                k = j;
            }
        }
        tot += mincost;
        lowcost[k] = 0;
        for (int j = 1; j <= n; j++) {
            if ( dis[k][j] != 0 && dis[k][j] < lowcost[j] ) {
                lowcost[j] = dis[k][j];
                closest[j] = k;
            }
        }
    }
    return tot;

}

int main() {
    ifstream cin("graph.in");
    cout << Prim(1) << endl;
    return 0;
}
